package com.tjec.project.mdmSynchronous.controller;

import com.alibaba.fastjson.JSONObject;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.page.TableDataInfo;
import com.tjec.project.mdmSynchronous.domain.MdmUser;
import com.tjec.project.mdmSynchronous.service.IBmsProjectLeaderService;
import com.tjec.project.mdmSynchronous.service.MdmUserService;
import com.tjec.project.msg.service.MsgService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author: VillWang
 * @Date: 2020/5/19 17:52
 */
@RestController
@RequestMapping("/api/user")
public class MdmUserController extends BaseController {
    @Autowired
    private MdmUserService mdmUserService;
    @Autowired
    private MsgService msgService;

    @Autowired
    private IBmsProjectLeaderService bmsProjectLeaderService;
    /**
     * 查询行政组织架构列表
     */
    @PreAuthorize("@ss.hasPermi('api:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(MdmUser mdmUser)
    {
    	List<MdmUser> list = new ArrayList<MdmUser>();
    	
        List<MdmUser> res =mdmUserService.selectMdmUserByName(mdmUser);
        if(res !=null ) {
        	list = res;
        }
        /*BmsProjectLeader bmsProjectLeader = new BmsProjectLeader();
        bmsProjectLeader.setJobNo(mdmUser.getJobNo());
        bmsProjectLeader.setUserName(mdmUser.getUserName());
        List<BmsProjectLeader> bmsProjectLeaders = bmsProjectLeaderService.selectBmsProjectLeaderNotSysUser(bmsProjectLeader);
        for (BmsProjectLeader projectLeader : bmsProjectLeaders) {
            MdmUser mu = new MdmUser();
            mu.setGlobalId(projectLeader.getUserGlobalid());
            mu.setJobNo(projectLeader.getJobNo());
            mu.setUserName(projectLeader.getUserName());
            mu.setPhoneNumber(projectLeader.getPhoneNumber());
            mu.setPersonnelDept(projectLeader.getPersonnelDept());
            list.add(mu);
        }*/
        return getDataTable(list);
    }
    
    @ApiOperation("测试使用")
    @PostMapping("/test")
    public JSONObject updateUserJobNo(String content, String phone) {
        JSONObject result = new JSONObject();
        System.out.println(content+phone);
        //msgService.sendMsg(phone,content);
        //ArrayList<String> strings = new ArrayList<>();
        //strings.add(content);
        //msgService.SendMsg(strings,content);
        //result.put("map",msm.getSmsIDList());
        msgService.SendMsg2(phone,content);
        return result;
    }

}

